import pygame, sys, os, gameview.utilities
from pygame.locals import *

class FontMap:
	def __init__(self,imageName, charWidth, charHeight):
		self.fontmap_surface, self.fontmap_rect = gameview.utilities.load_image("fontmap.gif",gameview.utilities.parse_webcolor("000000"))
		self.font_cell_width = self.fontmap_rect.width/charWidth
		self.font_cell_height = self.fontmap_rect.height/charHeight
	def get_unitsize(self):
		return (self.font_cell_width,self.font_cell_height)
	def get_lettersurface (self, c,color=(255,255,255)):
		ic = ord(c)
		x = ic%16*self.font_cell_width
		y = ic/16*self.font_cell_height
		letterSurface = self.fontmap_surface.subsurface(Rect(x,y,self.font_cell_width,self.font_cell_height))
		tint = pygame.Surface(letterSurface.get_size())
		tint.fill(color)
		tint.blit(letterSurface,(0,0),None,BLEND_MULT)
		tint.set_colorkey(Color("black"))
		return tint

	
